package com.shared.job;

import com.shared.dao.PGoodsMapper;
import com.shared.pojo.PGoods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
@Component
public class PgoodsJob {
    @Autowired
    private PGoodsMapper pGoodsMapper;
    //@Scheduled(cron = "0/10 * * * * ?")
    public void initGoods() {
        List<PGoods> list = pGoodsMapper.findAllGoods();
        for (PGoods pGoods : list) {
            if (pGoods.getStock() <= 0) {
                pGoodsMapper.deleteById(pGoods.getId());
            }
        }
    }
}
